package com.cn.sender;

import com.cn.entity.User;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by chenyuncong on 2019/5/22.
 */
@Component
public class HelloSender {
    @Autowired
    private AmqpTemplate template;

    public void send() {
        template.convertAndSend("queue","hello,rabbit~");
    }

    public void sendUser() {
        User user=new User();    //实现Serializable接口
        user.setUsername("hlhdidi");
        user.setPassword("123");
        template.convertAndSend("queueUser",user);
    }

    public void sendTopic(){
        template.convertAndSend("exchange","topic.messages","hello,rabbit-11111");
    }
}